package com.foxchen.fanjingmontainticket.enums;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum ProdInfoEnums {
    EAST_STUDENT("P2024053000000025701",48d,"东门-成人票（148）"),
    EAST_ADULT("P2024123100000019407",148d,"东门-学生票（48）"),
    WEST_ADULT("P2024123100000023301",112d,"西门-成人票（112）");

    final String prodId;
    final Double price;
    final String desc;

    ProdInfoEnums(String prodId, Double price, String desc) {
        this.prodId = prodId;
        this.price = price;
        this.desc = desc;
    }

    public static Double getPriceByProdId(String prodId) {
        return Arrays.stream(ProdInfoEnums.values()).filter(data -> data.prodId.equals(prodId)).findAny().orElseThrow(() -> new RuntimeException("can not find price by prodId: " + prodId)).getPrice();
    }

    public static String getDescByProdId(String prodId) {
        return Arrays.stream(ProdInfoEnums.values()).filter(data -> data.prodId.equals(prodId)).findAny().orElseThrow(() -> new RuntimeException("can not find price by prodId: " + prodId)).getDesc();
    }
}
